function [ result ] = laplacianpyr( CFs,kernel,image,n,N )
%LAPLACIANPYR Summary of this function goes here
%
%   Detailed explanation goes here

binomial=imfilter(image,kernel);
down_sample=impyramid(binomial,'reduce');
up_expand=impyramid(down_sample,'expand');
after_up=imfilter(up_expand,kernel);

%get min size
[image_w,image_h]=size(image);
[after_up_w,after_up_h]=size(after_up);
for_w=min(image_w,after_up_w);
for_h=min(image_h,after_up_h);
for_enhance=image;
for_enhance(1:for_h,1:for_w)=image(1:for_h,1:for_w)-after_up(1:for_h,1:for_w);
size(for_enhance),size(image);
if (n==2)
    I_EN_LOWER=down_sample;
else
    I_EN_LOWER=laplacianpyr(CFs,kernel,down_sample,n-1,N);
end;

I_EN_LOWER_UP=impyramid(I_EN_LOWER,'expand');
I_EN_LOWER_EXPAND=imfilter(I_EN_LOWER_UP,kernel);

% get min size
[exp_w,exp_h]=size(I_EN_LOWER_EXPAND);
[enhance_w,enhance_h]=size(for_enhance);
for_w=min(enhance_w,exp_w);
for_h=min(enhance_h,exp_h);
result=image;
result(1:for_h,1:for_w)=I_EN_LOWER_EXPAND(1:for_h,1:for_w)+for_enhance(1:for_h,1:for_w)*CFs(N-n+1);
end

